<?php
if(isset($_SESSION['tabReservations'])) {
// 	$_SESSION['tabReservations']) et un array contenant des $tabResMatCat
// 	$tabResMatCat sont des tableaux contenant une reservation, un materiel et une categorie associes
// 	pour eviter de faire des requetes BD
	foreach ($_SESSION['tabReservations'] as $tabResMatCat) {
		
		$tabReservations[] = array(	'reservation' => unserialize($tabResMatCat['reservation']),
									'materiel' => unserialize($tabResMatCat['materiel']),
									'categorie' => unserialize($tabResMatCat['categorie']));
	}
}

if(isset($_POST["action"])&&$_POST["action"]=="valider") {
	if(isset($_POST["valider"])) {
		$idClient = $client->getId();
	
		foreach ($tabReservations as $tabResMatCat) {
			$tabResMatCat['reservation']->ajoutBD();
		}
		unset($_SESSION['tabReservations']);
		echo 'r&eacute;servation valid&eacute;';
		header("Location:mesReservations.php");
		exit();
	}
	else if(isset($_POST["reserver"])) {
		header("Location:formReservation.php?action=ajouter");
		exit();
	}
}
